
import { BaseEntityService } from "./base-entity.service";
import httpClient from "./http-client";

export class SysPositionService extends BaseEntityService {
    baseUrl = "/api/v1.0/admin/position";

    async findPositionsByUserId(userId) {
        return httpClient.get(`${this.baseUrl}/${userId}/positions`).then((res) => {
            if (res.data.data) {
                const tree = res.data.data;
                return Promise.resolve(tree);
            } else {
                throw "no data";
            }
        });
    }

    async assign(param) {
        const body = {
            ...param,
        }
        return httpClient.post(`${this.baseUrl}/assign`, body);
    }

    async cancelAssign(param) {
        const body = {
            ...param,
        }
        return httpClient.post(`${this.baseUrl}/cancel-assign`, body);
    }
}

const positionService = new SysPositionService();

export default positionService;